package org.example.library_management_system.Model;

import lombok.Data;
import org.example.library_management_system.enums.ResultStatus;

@Data
public class Result<T> {
    private ResultStatus code;
    private String msg;
    private T Data;


    public static <T>Result success(T data){
        Result result = new Result();
        result.setCode(ResultStatus.SUCCESS);
        result.setMsg("登录中...");
        result.setData(data);
        return result;
    }

    public static Result noLogin(){
        Result result = new Result();
        result.setCode(ResultStatus.UNLOGIN);
        result.setMsg("未登录");
        result.setData(null);
        return result;
    }

    public static Result fail(String message){
        Result result = new Result();
        result.setCode(ResultStatus.FAIL);
        result.setMsg(message);
        result.setData(null);
        return result;
    }
}
